package com.lrkj.framework.websocket.model;

import org.springframework.web.socket.WebSocketSession;

public class WebSocketUserProp {
    private MessageClient client;
    private String id;

    public WebSocketUserProp() {
    }

    public MessageClient getClient() {
        return this.client;
    }

    public void setClient(MessageClient client) {
        this.client = client;
    }

    public String getId() {
        return this.id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public static WebSocketUserProp fromSession(WebSocketSession session) {
        WebSocketUserProp prop = new WebSocketUserProp();
        prop.setClient(MessageClient.valueOf((String) session.getAttributes().get("KEY_CLIENT")));
        prop.setId(session.getAttributes().get("KEY_USER_ID").toString());
        return prop;
    }
}
